/******************************************************************************
 *
 * @file       clickedlabel.h
 * @brief      自定义标签
 *
 * @author     ario
 * @date       2024/05/31
 * @history
 *****************************************************************************/

#ifndef CLICKEDLABEL_H
#define CLICKEDLABEL_H

#include <QLabel>
#include "global.h"

class ClickedLabel : public QLabel
{
    Q_OBJECT
public:
    ClickedLabel(QWidget *parent = nullptr);
    ~ClickedLabel();

    void SetState(QString normal = "", QString normal_hover = "", QString normal_press = "",
                  QString selected = "", QString selected_hover = "", QString selected_press = "");
    ClickLbState GetCurState();
    bool SetCurState(ClickLbState state);
    void ResetNormalState();

protected:
    // 重写鼠标按下事件
    void mousePressEvent(QMouseEvent *event) override;
    // 重写鼠标抬起事件
    void mouseReleaseEvent(QMouseEvent *event) override;
    // 重写鼠标进入事件
    virtual void enterEvent(QEvent *event) override;
    // 重写鼠标移出事件
    virtual void leaveEvent(QEvent *event) override;

private:
    QString _normal;            // 普通状态
    QString _normal_hover;      // 普通鼠标悬浮状态
    QString _normal_press;      // 普通鼠标按下状态
    QString _selected;          // 选中状态
    QString _selected_hover;    // 选中鼠标悬浮状态
    QString _selected_press;    // 选中鼠标按下状态

    ClickLbState _curState;     // 标签当前状态

signals:
    void clicked(QString, ClickLbState); // 标签被按下
};

#endif // CLICKEDLABEL_H
